﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Scala.Compiler.Ast
{
    public class Arg:Tree
    {
        private readonly string _name;
        private readonly Expression _expression;

        public Arg(Expression expression)
            : this("", expression) { }

        public Arg(string name, Expression expression)
        {
            _name = name;
            _expression = expression;
        }

        public string Name { get { return _name; } }
        public Expression Expression { get { return _expression; } }

        public override void Walk(ScalaWalker walker)
        {
            if (walker.Walk(this))
            {
                if (Expression != null)
                {
                    Expression.Walk(walker);
                }
            }
            walker.PostWalk(this);
        }

        public override Microsoft.Scripting.Ast.Expression Reduce()
        {
            return Expression.Reduce();
        }
    }
}
